Merge hw tests with existing emu - #592
Conversation
There was a problem hiding this comment.
Copilot encountered an error: Your billing is not configured or you have Copilot licenses from multiple standalone organizations or enterprises. To use premium requests, select a billing entity via the GitHub site, under Settings > Copilot > Features.
|
@microsoft-github-policy-service agree company="Microsoft" |
There was a problem hiding this comment.
Copilot encountered an error: Your billing is not configured or you have Copilot licenses from multiple standalone organizations or enterprises. To use premium requests, select a billing entity via the GitHub site, under Settings > Copilot > Features.
There was a problem hiding this comment.
Copilot encountered an error: Your billing is not configured or you have Copilot licenses from multiple standalone organizations or enterprises. To use premium requests, select a billing entity via the GitHub site, under Settings > Copilot > Features.
There was a problem hiding this comment.
Copilot encountered an error: Your billing is not configured or you have Copilot licenses from multiple standalone organizations or enterprises. To use premium requests, select a billing entity via the GitHub site, under Settings > Copilot > Features.
There was a problem hiding this comment.
Copilot encountered an error: Your billing is not configured or you have Copilot licenses from multiple standalone organizations or enterprises. To use premium requests, select a billing entity via the GitHub site, under Settings > Copilot > Features.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 20 out of 20 changed files in this pull request and generated 3 comments.
Comments suppressed due to low confidence (2)
ddi/tbor/types/tests/harness/mod.rs:36
- This module doc says in-session tests are gated with
cfg(not(any(feature = "mock", feature = "sock"))), but the updated command tests (e.g.open_session.rs,psk_change.rs) are no longer gated off undersockand will run there. The documentation should match the actual cfg regime (likely only excludingmock).
//! on-silicon test runs; the in-session command tests run under
//! this backend too (they are gated
//! `#![cfg(not(any(feature = "mock", feature = "sock")))]`, which
//! admits both `emu` and the no-feature native OS build). The
ddi/tbor/types/tests/commands/open_session.rs:705
- This diagnostic message still references the old test name (
open_session_multi_threaded_all_should_open). If the test is renamed to reflect its real assertions, the log prefix should be updated too to avoid confusion when reading CI output.
eprintln!(
"open_session_multi_threaded_all_should_open: FW accepted all {MULTI_THREADED_TOTAL} \
concurrent sessions without emitting any table-full rejection; race between success \
and rejection branches not exercised at this thread count",
);
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 38 out of 38 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (4)
ddi/tbor/types/tests/harness/fixture.rs:111
open_dev()now unconditionally callsdev.erase(), but the socket backend implementsDdiDev::eraseasUnsupportedCmd(seeddi/sock/src/dev.rs:301-303). This makes--features sockruns panic during fixture setup, before any tests execute. Consider skipping the erase step for the sock backend (or implementing erase support in the socket transport) so sock tests can run.
let path = info.path.clone();
let dev = ddi.open_dev(&path).expect("open test backend device");
dev.erase()
.expect("open_dev: factory-reset backend before test");
ddi/tbor/types/tests/harness/fixture.rs:86
unsafe impl Send for TestDevrelies on a non-enforced invariant ("only secondaries are sent across threads"). If a future test accidentally moves a primaryTestDev(with_guard: Some(...)) to another thread, dropping it there may violate the mutex’s thread-affinity requirements and turn into UB. A safer pattern is to make the primary/secondary distinction explicit in the type system (e.g., separatePrimaryTestDev/SecondaryTestDevtypes, or an enum where only the secondary variant isSend) so the compiler enforces the invariant.
#[allow(unsafe_code)]
unsafe impl Send for TestDev {}
ddi/tbor/types/tests/commands/part_init/happy_path.rs:317
- Same issue as
part_init_determinism: this test callsctx.erase()and will fail under--features sockbecause the socket backend does not supportDdiDev::erase(UnsupportedCmd). Gate it off for sock (or implement erase in the socket transport).
#[test]
fn part_init_pta_pub_differs_when_include_fmc_cdi_flag_toggled() {
ddi/tbor/types/Cargo.toml:39
- With the
hw-testsopt-in feature removed and no default feature set,cargo test -p azihsm_ddi_tbor_typeswill now select the native OS backend (real hardware) by default. Combined with the updated fixture doing a factory reset, this can cause surprising/destructive behavior on developer machines and will panic on hosts without a device. Consider restoring an explicit opt-in for hardware runs (or setting an explicit default test backend) so the defaultcargo testpath is non-destructive and does not require silicon.
[features]
# Forward backend selection to the azihsm_ddi facade so the integration
# test binary picks up the right backend. The same tests run across every
# transport — choose one with `--features emu` / `mock` / `sock`.
emu = ["azihsm_ddi/emu"]
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 38 out of 38 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (5)
ddi/win/src/dev.rs:682
- Same issue as above:
NoValidSessionIdis currently remapped toTborStatus::SessionNotFound, but for TBOR callers this should preserve the driver-layer scoping signal usingTborStatus::FileHandleNoExistingSession(numeric encoding matches theDdiStatusvariant).
ddi/tbor/types/tests/harness/fixture.rs:98 - Doc comment is now inaccurate: the harness is gated out only for
--features mock, but this comment says "mock/sock builds gate the whole harness out". Also,open_devis reachable under--features sockas well.
/// Acquire the test lock, open the configured backend device, and
/// factory-reset it before use. Only reachable under `--features emu`
/// or the no-feature (hw) build — mock/sock builds gate the whole
/// harness out at the crate root.
ddi/tbor/types/tests/harness/fixture.rs:86
unsafe impl Send for TestDevmakes the primary (lock-holding)TestDevmovable across threads even though the implementation relies on it staying on the lock-acquiring thread. This invariant isn’t enforced by the type system, so it’s easy for future refactors to accidentally introduce UB. Consider splitting the types (e.g.,PrimaryTestDevholding theMutexGuardandSecondaryTestDevwithout it) so only the secondary handle isSendwithoutunsafe.
// secondaries (with `_guard: None`) are sent into `thread::scope`
// worker threads, and rustc cannot prove that at compile time
// because both variants share the same type.
#[allow(unsafe_code)]
unsafe impl Send for TestDev {}
ddi/win/src/dev.rs:666
map_ioctl_status_tbormaps the driver’sNoExistingSession(per-file-handle session scoping) toTborStatus::SessionNotFound. This loses the driver-vs-FW distinction and contradicts the doc comment that this helper is a pureFileHandle*type-level remap (andTborStatusdoes defineFileHandleNoExistingSession).
This issue also appears on line 680 of the same file.
ddi/nix/src/dev.rs:723
map_ioctl_status_tborcurrently mapsNoExistingSessiontoTborStatus::SessionNotFound, butTborStatusprovidesFileHandleNoExistingSessionfor this driver-layer scoping rejection. Using theFileHandle*status keeps TBOR error typing consistent with theDdiStatusmapping inmap_ioctl_status.
Ok(McrCpGenericIoctlErrorKind::NoExistingSession) => {
return Err(DdiError::TborStatus(TborStatus::SessionNotFound));
}
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 39 out of 39 changed files in this pull request and generated 3 comments.
Suppressed comments (3)
ddi/tbor/types/tests/harness/fixture.rs:99
- The doc comment claims
open_devis unreachable under--features sock, but the test binary includesharnessundercfg(not(feature = "mock")), sosockbuilds do compile and call this harness. This comment is now misleading for readers trying to understand which backends run the integration tests.
/// Acquire the test lock, open the configured backend device, and
/// factory-reset it before use. Only reachable under `--features emu`
/// or the no-feature (hw) build — mock/sock builds gate the whole
/// harness out at the crate root.
///
ddi/tbor/types/Cargo.toml:41
- Removing the
hw-testsopt-in feature means the no-feature build now targets the native OS backend and will panic inopen_dev()if no physical device/driver is present. That changes the default developer experience forcargo test -p azihsm_ddi_tbor_typeson machines without hardware and may also affect CI if any jobs build tests without--features emu/sock. Consider restoring an explicit opt-in (feature or env-gate) for on-silicon runs, or makingemuthe default feature.
[features]
# Forward backend selection to the azihsm_ddi facade so the integration
# test binary picks up the right backend. The same tests run across every
# transport — choose one with `--features emu` / `mock` / `sock`.
emu = ["azihsm_ddi/emu"]
mock = ["azihsm_ddi/mock"]
sock = ["azihsm_ddi/sock"]
ddi/tbor/types/tests/harness/session_guard.rs:12
- This intra-doc link points to
crate::harness::open_dev, butopen_devis no longer re-exported fromharness/mod.rs(it now lives incrate::harness::fixture). If rustdoc broken-link warnings are denied in CI, this can fail the build; even if not, it’s misleading to readers.
//! is process-global and the per-test serialisation provided by
//! [`open_dev`](crate::harness::open_dev)'s `TEST_LOCK` only orders
//! execution; it does not clean up leaked slots. The guard
This PR merges all the existing HW tests with emu tests. Most of the tests are working both on emu and HW.
There are quite a few HW only tests that need emu support. This should be fixed in the follow-up PR.